package fr.afcepf.atod19.appli.util;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

//avec <artifactId>spring-aop</artifactId> 
//+ aspectjrt , aspectjweaver dans pom.xml
@Aspect
public class MyLogAspect {
	@Around("execution(* fr.afcepf.atod19.appli.service.*.*(..))")
	public Object doXxxLog(ProceedingJoinPoint pjp) throws Throwable {
		System.out.println("<< trace == debut == "
				+ pjp.getSignature().toLongString() + " <<");
		long td = System.nanoTime();
		Object objRes = pjp.proceed();
		long tf = System.nanoTime();
		System.out.println(">> trace == fin == "
				+ pjp.getSignature().toShortString() + " [" + (tf - td)
				/ 1000000.0 + " ms] >>");
		return objRes;
	}
}
